local function Fn()
    local Fx = Class()


    function Fx:Init(NPC_BASE_LIB)
        ---------------------------------------------------------------------------------------------------------------------------

        -- if NPC_BASE_LIB.inst == nil or NPC_BASE_LIB.inst:HasTag("player") then
        --     return
        -- end

        function NPC_BASE_LIB:Action_Give()
            self.inst.sg:GoToState("give")
        end

        function NPC_BASE_LIB:Action_Attack()
            self.inst.sg:GoToState("attack")
        end
        function NPC_BASE_LIB:Action_Chop()
            self.inst.sg:GoToState("chop_start")
        end

        function NPC_BASE_LIB:Action_WhipAttack()
            self.inst.sg:GoToState("dojostleaction")
        end
        function NPC_BASE_LIB:Action_Gita()
            self.inst.sg:GoToState("play_strum")
        end
        function NPC_BASE_LIB:Action_Castspell()            
            self.inst.sg:GoToState("castspell")
        end

        function NPC_BASE_LIB:Action_Horn(fn,no_end_return)
            if self.tempData.Action_Horn == nil then
                self.tempData.Action_Horn = {}
            end
            local tempData = self.tempData.Action_Horn

            if no_end_return ~= true and tempData.play_horn_end == true then
                tempData.play_horn_end = nil
                return true
            end
            if tempData.playing_horn == true then
                return false
            end
            tempData.playing_horn = true
            self.inst.sg:Stop()
            self.inst.sg:GoToState("play_horn")
            self.inst:DoTaskInTime(2.8,function()
                if fn and type(fn) == "function" then                
                    fn(self.inst)          
                end
                self.inst.sg:GoToState("idle")
                self.inst.sg:Start()
                tempData.playing_horn = false
                tempData.play_horn_end = true
            end)

            self.inst:DoTaskInTime(1,function()
                self.inst.SoundEmitter:PlaySound("dontstarve/common/horn_beefalo")
            end)
            
        end


        function NPC_BASE_LIB:Action_Bugnet(fn,no_end_return)
            if self.tempData.Action_Bugnet == nil then
                self.tempData.Action_Bugnet = {}
            end
            local tempData = self.tempData.Action_Bugnet

            if no_end_return ~= true and  tempData.after_use_bugnet == true then
                tempData.after_use_bugnet = nil
                return true
            end

            if tempData.using_bugnet == true then
                return false
            end
            tempData.using_bugnet = true
            self.inst.sg:Stop()
            self.inst.AnimState:PlayAnimation("bugnet_pre")
            self.inst.AnimState:PushAnimation("bugnet")
            -- self.inst.AnimState:PushAnimation("idle",true)

            self.inst:DoTaskInTime(0.8,function()
                if fn and type(fn) == "function" then
                    fn(self.inst)
                end
                self.inst.sg:GoToState("idle")
                self.inst.sg:Start()
                tempData.using_bugnet = false
                tempData.after_use_bugnet = true
            end)

            self.inst:DoTaskInTime(0.3,function()
                self.inst.SoundEmitter:PlaySound("dontstarve/wilson/use_bugnet", nil, nil, true)
            end)

        end
        ---------------------------------------------------------------------------------------------------------------------------
    end

    return Fx
end

return Fn